package com.framework.modules.dataview.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.common.utils.PageUtils;
import com.framework.common.utils.Query;
import com.framework.modules.dataview.dao.ViewUserInfoCommentsDao;
import com.framework.modules.dataview.entity.ViewUserInfoCommentsEntity;
import com.framework.modules.dataview.service.ViewUserInfoCommentsService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@Service("ViewUserInfoCommentsService")
public class ViewUserInfoCommentsServiceImpl extends ServiceImpl<ViewUserInfoCommentsDao, ViewUserInfoCommentsEntity> implements ViewUserInfoCommentsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        List<String> columns=new ArrayList<>();
        columns.add("adddate");
        Page<ViewUserInfoCommentsEntity> page = this.selectPage(
                new Query<ViewUserInfoCommentsEntity>(params).getPage(),
                new EntityWrapper<ViewUserInfoCommentsEntity>()
                        .where("post_id={0}",params.get("postId"))
                        .eq("state", params.get("state")).orderDesc(columns)
        );
        return new PageUtils(page);
    }

}
